package oa.util;

import java.util.Collection;

import org.apache.struts2.ServletActionContext;

import oa.domain.system.Privilege;
import oa.domain.system.User;

public class OAUtils {

	public static void putUserToSession(User user){ //把user放到session之中
		
		ServletActionContext.getRequest().getSession().setAttribute("user", user);
	}
	
	public static void putFunctionsToSession(Collection<Privilege> privileges){
		ServletActionContext.getRequest().getSession().setAttribute("privileges", privileges);
	}
	
	public static User getUserFromSession(){
		return (User) ServletActionContext.getRequest().getSession().getAttribute("user");
	}
	
	public static String getIpAddress()
	{
		return ServletActionContext.getRequest().getRemoteAddr();
	}
}
